package com.example;

import java.util.List;

import winterwell.jtwitter.Twitter.Status;
import android.os.Handler;
import android.os.Message;
import android.widget.Toast;

public class ListStatusMessageHandler extends Handler {
	private StatusAdapter m_adapter;

	public ListStatusMessageHandler(StatusAdapter adapter) {
		m_adapter = adapter;
	}

	@SuppressWarnings("unchecked")
	@Override
	public void handleMessage(Message msg) {
		if (msg.obj instanceof List) {
			List<Status> timeline = (List<Status>) msg.obj;
			for (Status status : timeline) {
				m_adapter.add(status);
			}
		} else if (msg.obj instanceof String) {
			String message = (String) msg.obj;
			Toast.makeText(m_adapter.getContext(), message, Toast.LENGTH_LONG)
					.show();
		}
	}
}
